/**
 * Copyright 2011 Poltman.Ltd; www.poltman.com. All rights reserved.		
 *
 * This file is part of the dspace-poltman project http://www.poltman.com.
 *
 * This is free software; you can redistribute it and/or modify it under
 * the terms of DuraSpace DSpace license detailed in the LICENSE and NOTICE 
 * files at the root of the source tree and available online at
 * http://www.dspace.org/license/
 * 
 */

package com.poltman.dscentral.db.service.dspace.impl;


import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import com.poltman.dscentral.db.entity.dspace.Epersongroup2epersonEntity;
import com.poltman.dscentral.db.exceptions.RepositoryAccessException;
import com.poltman.dscentral.db.exceptions.RepositoryException;
import com.poltman.dscentral.db.repository.dspace.Epersongroup2epersonRepository;
import com.poltman.dscentral.db.service.dspace.Epersongroup2epersonService;




/**
 * 
 * @author Zbigniew Ciok; z.ciok@poltman.com
 * @version $Revision: 1759 $
 *
 */
@Repository
@Service("epersongroup2epersonService")
public class Epersongroup2epersonServiceImpl implements Epersongroup2epersonService {
	
	private static Logger log = Logger.getLogger(Epersongroup2epersonServiceImpl.class);
	
	@Autowired
	private Epersongroup2epersonRepository epersongroup2epersonRepository;
	
	@Override
	public Epersongroup2epersonEntity findByEpersonGroupIdAndEpersonId(Integer epersonGroupId, Integer epersonId) throws Exception {
		@SuppressWarnings("unchecked")
		List<Epersongroup2epersonEntity> epersongroup2epersonEntity = (List<Epersongroup2epersonEntity>) epersongroup2epersonRepository.findByEpersonGroupIdAndEpersonId(epersonGroupId, epersonId);
		if (epersongroup2epersonEntity == null) return null;
		if (epersongroup2epersonEntity.size() != 1) return null;
		return epersongroup2epersonEntity.get(0);
	}
}